// 百家姓（常见部分，够用了）
const surnames = [
  "赵","钱","孙","李","周","吴","郑","王","冯","陈","褚","卫",
  "蒋","沈","韩","杨","朱","秦","尤","许","何","吕","施","张",
  "孔","曹","严","华","金","魏","陶","姜","戚","谢","邹","喻",
  "柏","水","窦","章","云","苏","潘","葛","范","彭","郎","鲁"
];

// 随机汉字生成器（常用字区间）
function getRandomChineseChar() {
  const start = 0x4E00;
  const end = 0x9FA5;
  return String.fromCharCode(Math.floor(Math.random() * (end - start)) + start);
}

// 随机名字（百家姓 + 1~2个字）
function getRandomName() {
  const surname = surnames[Math.floor(Math.random() * surnames.length)];
  const givenNameLength = Math.random() > 0.5 ? 1 : 2;
  let givenName = "";
  for (let i = 0; i < givenNameLength; i++) {
    givenName += getRandomChineseChar();
  }
  return surname + givenName;
}

// 随机短语生成器
function getRandomPhrase(words, count = 2) {
  const result = [];
  for (let i = 0; i < count; i++) {
    result.push(words[Math.floor(Math.random() * words.length)]);
  }
  return result.join("，");
}

export default function generateRandomData(count = 10) {
  const hobbyWords = ["喝酒", "舞剑", "作诗", "绘画", "弹琴", "数学", "物理", "炼丹", "游历", "下棋", "写字", "读书", "写信"];
  const occupationWords = ["文学家", "科学家", "艺术家", "音乐家", "哲学家", "医生", "政治家", "军事家", "商人"];
  const personalityWords = ["浪漫", "豪爽", "亲切", "和蔼", "冷静", "理智", "豪放", "直率", "细腻", "温柔", "睿智", "幽默", "沉稳", "坚毅"];

  const data = [];
  for (let i = 0; i < count; i++) {
    data.push({
      name: getRandomName(),
      age: String(Math.floor(Math.random() * 60) + 20),
      hobby: getRandomPhrase(hobbyWords, Math.floor(Math.random() * 3) + 1),
      occupation: occupationWords[Math.floor(Math.random() * occupationWords.length)],
      height: `${Math.floor(Math.random() * 30) + 160}cm`,
      personality: getRandomPhrase(personalityWords, 2)
    });
  }
  return data;
}
